package LeetCode;

import java.util.*;

public class LeetCodeMain15 {
//    int[][] result;
//    public int[][] floodFill(int[][] image, int sr, int sc, int newColor) {
//        result=image;
//        backing(image,sr,sc,newColor,result);
//        return result;
//    }
//    public void backing(int[][] image,int sr,int sc,int newColor,int[][] result){
//        for (int i = sr; i < image.length; i++) {
//            for (int j = sc; j < image[i].length; j++) {
//                if (image[i][j]==image[sr][sc]){
//
//                }
//            }
//        }
//    }
    int count=0;
    StringBuilder str=new StringBuilder();
    public int numTilePossibilities(String tiles) {
        char[] ch=tiles.toCharArray();
        boolean[] booleans=new boolean[ch.length];
        Arrays.sort(ch);
        back(ch,booleans);
        return count;
    }
    public void back(char[] ch,boolean[] booleans){
        if (str.length()>0){
            count++;
        }
        for (int i = 0; i < ch.length; i++) {
            if (i>0&&ch[i]==ch[i-1]&&booleans[i-1]==false){
                continue;
            }
            if (booleans[i]==false){
                booleans[i]=true;
                str.append(ch[i]);
                back(ch,booleans);
                str.deleteCharAt(str.length()-1);
                booleans[i]=false;
            }
        }
    }

    public static void main(String[] args) {
        char[] chars=new char[3];
        chars[0]='s';
        chars[1]='z';
        chars[2]='a';
        Arrays.sort(chars);
        System.out.println(chars);
    }
}
